import com.jme3.material.Material;
import com.jme3.material.RenderState.FaceCullMode;
import com.jme3.texture.Texture;


public class Materials {
	
	private static Material dirtMat;
	private static Material stoneMat;
	private static Material woodMat;
	static Texture dirtTex;
	static Texture stoneTex;
	static Texture woodTex;
	
	
	static Material getMaterial(int type)
	{
		if(type==3)
			return getDirt();
		else if(type==2)
			return getStone();
		else if(type==1)
			return getWood();
		
		return null;
	}
	
	public static Material getDirt()
	{
		if(dirtTex==null)
		{
			dirtTex = Engine.getEngine().getAssetManager().loadTexture("Textures/box.png");
			dirtTex.setMagFilter(Texture.MagFilter.Nearest);
			dirtTex.setMinFilter(Texture.MinFilter.NearestLinearMipMap);
		}
		if(dirtMat==null)
		{
			dirtMat = new Material(Engine.getEngine().getAssetManager(), "Common/MatDefs/Misc/Unshaded.j3md");
			dirtMat.setTexture("ColorMap", dirtTex);
		}
		return dirtMat;
	}
	
	public static Material getStone()
	{
		if(stoneTex==null)
		{
			stoneTex = Engine.getEngine().getAssetManager().loadTexture("Textures/stone.png");
			stoneTex.setMagFilter(Texture.MagFilter.Nearest);
			stoneTex.setMinFilter(Texture.MinFilter.NearestLinearMipMap);
		}
		if(stoneMat==null)
		{
			stoneMat = new Material(Engine.getEngine().getAssetManager(), "Common/MatDefs/Misc/Unshaded.j3md");
			stoneMat.setTexture("ColorMap", stoneTex);
		}
		return stoneMat;
	}
	public static Material getWood()
	{
		if(woodTex==null)
		{
			woodTex = Engine.getEngine().getAssetManager().loadTexture("Textures/wood.png");
			woodTex.setMagFilter(Texture.MagFilter.Nearest);
			woodTex.setMinFilter(Texture.MinFilter.NearestLinearMipMap);
		}
		if(woodMat==null)
		{
			woodMat= new Material(Engine.getEngine().getAssetManager(), "Common/MatDefs/Misc/Unshaded.j3md");
			woodMat.setTexture("ColorMap", woodTex);
		}
		return woodMat;
	}
}